import { Column, Entity, Index } from 'typeorm';
import { CommonEntity, CommonStatus } from '~/common/entity/common.entity';
import { MissionType } from '../mission.model';

@Entity('ah_mission_log')
@Index(['id'])
export class MissionLogEntity extends CommonEntity {
  // 任务ID
  @Column({
    type: 'int',
    comment: '任务ID',
    name: 'mission_id',
  })
  missionId: number;

  @Column({
    type: 'tinyint',
    width: 1,
    name: 'is_finished',
    default: CommonStatus.YES,
  })
  isFinished: number;

  @Column({
    type: 'int',
    comment: '用户ID',
    name: 'user_id',
  })
  userId: number;

  @Column({
    type: 'int',
    comment: '租户ID',
    name: 'tenant_id',
    nullable: true,
  })
  tenantId: number;

  @Column({
    type: 'int',
    comment: '疾病ID',
    name: 'disease_id',
    nullable: true,
  })
  diseaseId: number;

  @Column({
    type: 'enum',
    enum: MissionType,
    comment: '任务类型',
    name: 'mission_type',
    nullable: true,
  })
  missionType: MissionType;

  @Column({
    type: 'varchar',
    length: 255,
    comment: '关联ID（根据任务类型区分：CATALOG-目录ID，RECOMMEND-文章ID，EXAM-答卷ID，QNAIRE-问卷ID）',
    name: 'related_id',
    nullable: true,
  })
  relatedId: string;

  @Column({
    type: 'decimal',
    precision: 10,
    scale: 2,
    comment: '分数',
    name: 'score',
    nullable: true,
  })
  score: number;
}
